Amazing explanation.. Helped a lot. Thanks.
Thanks for the feedback.
Here comes Yet Another Fool with Yet Another Case of the 404 error 'requested resource is not available'. I'm working on a Mac, though, which might somehow require something other than what you describe in your procedure. I noted your admonition to use /HelloWorldServlet/HelloWorld and implemented it. I assume, by the way, that this applies to line 15, the @WebServlet() line.
That didn't work, so I guessed that it needs a proper filepath to the HelloWorld class, which I tried in lieu of the "/HelloWorldServlet/HelloWord" value. I entered the entire filepath starting at /HelloWorld directory, but that didn't help.
Another possible source of trouble is that I installed the apache tomcat folder inside the workspace folder; I doubt this is a problem since tomcat is certainly operational.
I checked Eclipse's preferences just to be sure, and yes, its browser setting is the default system browser.
Could it be that the 'requested resource' is something other than the filepath to the HelloWorld servlet? Is it possible to get Tomcat to tell me what resource is not available?
I checked the console and note these reports:
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
Apr 7, 2013 10:20:14 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:HelloWorldServlet' did not find a matching property.
I can't figure out what they mean.
Thank bro
thanks alot
Thanks govardhan
After run on server showing
HTTP Status 404 - /HelloWorldServlet/
type Status report
message /HelloWorldServlet/
description The requested resource is not available.
but i use @WebServlet("/HelloWorld") and can not find the /HelloWorld in URL
So please give me a solution?
Please try /HelloWorldServlet/HelloWorld
Awesome Tutorial and well Explained in every step. Thank you So much for this , We are looking such more awesome tutorial from you :) .
Thanks for your feedback.
thanks man!
Can't thank you enough! Great step-by-step, I've been searching for awhile until now.
Thanks Mike...
Hi Abhijit,
I am getting error as 'This program cannot display the webpage' i tried all possible ways you have given in this post still the same error,even i tried to execute 'test-app' sample still error is same, Could you please help me out with this issue.
It is probably a web browser hijacker virus. Please try http://support.microsoft.com/k...
Excellent step-by-step instructions. Thank you so much for taking the time to put this together and post it. I too ran into the 404 error and had to add /HelloWorld to my URL to get the servlet to run.
We can run and open the servlet directly in broweser in two ways
1. Add the servlet mapping url in 'welcome-file-list' of web.xml
or
2. Right click on the servlet class (HelloWorld.java) and select from context menu 'Run As' --> 'Run on Server'.
As many people are not getting this 404 issue, I'll update the above tutorial as soon as possible to incorporate the above thing.
Thanks for your feedback Fred.
After run on server showing
HTTP Status 404 - /HelloWorldServlet/
type Status report
message /HelloWorldServlet/
description The requested resource is not available.
but i use @WebServlet("/HelloWorld") and can not find the /HelloWorld in URL
So please give me a solution?
If that war is deployed without any error then following url should work /HelloWorldServlet/HelloWorld
I original poster said that URL should work, but while in eclipse (and Chrome) I had to type in the servlet name as well /HelloWorldServlet/HelloWorld. Why, ???
Jeffery B. Rancier
Software Engineer
View Profile
"The beauty of the Second Amendment is that it will not be needed until they try to take it." - Thomas Jefferson
"The strongest reason for the people to retain the right to keep and bear arms is, as a last resort, to protect themselves against tyranny in government." - Thomas Jefferson
Hi Jeff, please go through the discussion with Aristos
Very nice! I'm still trying to figure out how to get the servlet from running in the instance of Tomcat in Eclipse and be able to publish and run from a browser. I'm using Tomcat 7, Juno Eclipse, and Java 1.7.0_07. I didn't find any google help for this.
Jeff Thanks. I didn't get the issue you are facing. Please provide more details. I'll try to help you.
The only issue that I'm having now is that I am attempting to access static content, but (the image) it doesn't appear. I do not get a 404 error, just no image. Do you add static content references from Eclipse? I thought the idea of using the IDE was to not have to modify files (web.xml, for example) from outside Eclipse?
Please tell me where you are keeping those image files inside your web application and how you are accessing them? It is weird that you are not getting 404 and image is not getting rendered at the same time.
Thanks for the reply. I had problems first of all with the jpg I was attempting to use, The browser simply could grok the dimensions without resizing. I wasted alot of time on that, but I learned alot on that road. I didn't realize that I could rendered the webpage(s) without publishing (from within Eclipse). I simply placed my static content in /HelloWorldServlet/WebContent/ and everything seems OK. Thanks for the tutorial, and the responses.
its too good and helped
Happy to hear that this post helped you. Thanks for the feedback.
Thanks alot it is so clear and really helps me
You are welcome. Thanks for the feedback.
Thank you very much. It is so clear.
Thanks punxlew.
could any one please suggest me a host where i can deploy my WAR application that needs a MY-SQL database?thanx in advance...
Please try free cloud paas www.appfog.com and if you need help you can browse my post http://www.srccodes.com/p/arti...
Port 8009 required by Tomcat v6.0 Server at localhost is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s). my prob when i try to run project(HELLOWORLD) in eclipse jee juno..could anyone please help me..thanx in advance....
To change the port number perform the following steps
1. Open server.xml file in <tomcat-installation-directory>/conf
2. find following similar tag in server.xml
<connector connectiontimeout="20000" port="8080" protocol="HTTP/1.1" redirectport="8443">
3. Change the port number (say 8080) to another free port (say 8081).
4. Save the file and restart the tomcat server</connector></tomcat-installation-directory>
thanx man...could you please suggest me a host where i can deploy my WAR application that needs a MY-SQL database?
Hello! Everything seems to be working fine when doing this but I have the following problem:
When I run the project on the server it does not automatically redirect me to the servlet but just to the Project name. For example, the url is this: http://localhost:8080/HelloWorldServlet instead of http://localhost:8080/HelloWorldServlet/HelloWorld
Of course when I manually type the correct url the page is working.
I tried to do the mapping manually from the web.xml but nothing changed.
Do you have any suggestion on this?
Thank you!
We can do it in two ways
1. Add the servlet mapping url in 'welcome-file-list' of web.xml
or
2. Right click on the servlet class (HelloWorld.java) and select from context menu 'Run As' --> 'Run on Server'.
Please let me know whether this worked for you or not.
Thanks.
Thank you for your quick reply!
I did both and here are the results:
1. I created a servlet-mapping for the HelloWorld servlet and added the url-pattern name in the welcome-file-list. Then when I run the project, the servlet is running normally and the "Hello World" message appears. However the url is still the old one "http://localhost:8080/HelloWorldServlet/". Is the url ok, or should it include the servlet name as well?
2. When directly running the project from the servlet class everything is running perfectly. The message appears and the url is the full one: http://localhost:8080/HelloWorldServlet/HelloWorld
However notice that the 2nd solution works only when I do no changes at the web.xml. If I first change the web.xml (as described in 1) I get a wrong url (when executing directly from the servlet class and not from the project): http://localhost:8080/HelloWorldServlet/servlet/com.examples.HelloWorld
So, in the end, my question is: If I have more than one servlets and they need to communicate, will the welcome list solution be enough, or do I need to change something else as well?
Thank you once again!
1. Yes both "http://localhost:8080/HelloWorldServlet/" and "http://localhost:8080/HelloWorldServlet/HelloWorld" are valid url for that servlet. Please refer the following url to know how welcome-file-list tag workshttp://docs.oracle.com/cd......
2. Obviously not. If I am not wrong, I think you are missing one basic requirement which is, deployed servlets will be accessed by end user using browser by providing corresponding mapping url. So there is no point in trying to run from IDE for multiple servlets.
iongion — Great, keep it up in the same idea, I like that you not only explained logging, but also, a little bit of maven, some things about a project layout (how to …
Ravinder Singh — thanks buddy ..